from django import forms
from django.shortcuts import render
from django.core.validators import RegexValidator


from app01.models import Usersinfo
from app01.utils import Bootstrap

class register(Bootstrap.BootStrapModelForm):
    password=forms.CharField(label='密码',widget=forms.PasswordInput)
    confirm_password=forms.CharField(label='确认密码',widget=forms.PasswordInput)
    mobile_phone=forms.CharField(label='手机号', validators=[RegexValidator (r'^1[3-9]\d{9}$','手机格式错误')])
    code=forms.CharField(label='验证码',widget=forms.TextInput)
    class Meta:
        model = Usersinfo
        fields = ['name','email','password','confirm_password','mobile_phone','code']


def register_list(request):
    form = register()
    return render(request, 'register.html', {'form': form})
